#include <bits/stdc++.h>
using namespace std;
const int N=1e5+50;
int n,q,l,r;
typedef long long ll;
const ll MOD=1e9+7;
char s[N];
ll Pow(ll a,ll n){
    ll ans=1;
    while(n){
        if(n%2){
            ans=(ans*a)%MOD;
        }
        a=(a*a)%MOD;
        n/=2;
    }
    return ans%MOD;
}
ll pre[N];
int main(void){
    scanf("%d%d",&n,&q);
    scanf("%s",s+1);
    for(int i=1;i<=n;i++){
        if(s[i]=='1'){
            pre[i]=pre[i-1]+1;
        }else{
            pre[i]=pre[i-1];
        }
    }
    while(q--){
        scanf("%d%d",&l,&r);
        ll one=pre[r]-pre[l-1];
        ll zero=(r-l+1)-one;
        ll t1=Pow(2,one)-1;
        ll t2=Pow(2,zero);
        ll t3=(t1%MOD*t2%MOD)%MOD;
        printf("%lld\n",t3);
    }
    return 0;
}